/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.report.loan;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.primefaces.context.RequestContext;
import org.primefaces.event.CloseEvent;
import src.Menu;
import src.MenuBean;
import src.report.ReportFilter;

/**
 *
 * @author Yusup Jauhari Shandi <in.visi>
 */
@ManagedBean
@SessionScoped
public class LoanReportBean implements Serializable{
    private List<Menu> availableMenu;
    private Menu SelectedReport;
    private ReportFilter reportFilter;
    private boolean showLookup=false;
    
    public LoanReportBean() {
        MenuBean menuBean = new MenuBean();
        Map<String,Object> filters = new HashMap<>();
        filters.put("menuType", "report");
        filters.put("menuGroup", "LOAN");
        filters.put("hide", -1);
        reportFilter = new ReportFilter();
        availableMenu = menuBean.getMenuByType(filters);
        this.SelectedReport = new Menu(-1, null, null, null, null, null, null, Integer.SIZE, null);
    }

    public ReportFilter getReportFilter() {
        return reportFilter;
    }

    public void setReportFilter(ReportFilter reportFilter) {
        this.reportFilter = reportFilter;
    }

    
    public List<Menu> getAvailableMenu() {
        return availableMenu;
    }

    public Menu getSelectedReport() {
        return SelectedReport;
    }

    public void setSelectedReport(Menu SelectedReport) {
        this.SelectedReport = SelectedReport;
    }
    
    public void executeReport(){
        Integer reportId = this.SelectedReport.getMenuId();
        /*  331 : rptPelunasanKredit
         *  332 : rptAccrualAnggaranKredit
         *  333 : rptAccrualPerorangan
         *  334 : rptAnalisaKolektibilitas
         * 335  : rptAngsuranKredit
         * 336  : rptJadwalAngsuranKredit
         * 337  : rptJadwalTagihanKredit
         * 338  : rptNominatifKreditPerGroup
         * 339  : rptNominatifKredit
         * 340  : rptNominatifPPAPWD
         * 341  : rptRealisasiKredit
         * 342  : rptRekapKredit
         * 343  : rptRiwayatKredit
         * 344  : rptTransaksiKredit
         * 345  : rptTunggakanKredit
         * 
         * 
         */
         switch (reportId) {
             case 331 : new RptPelunasanKreditBean().execute(reportFilter);break;
             case 335 : new RptAngsuranKreditBean().execute(reportFilter);break;
             case 336 : new RptJadwalAngsuranKreditBean().execute(reportFilter);break;
             case 337 : new RptJadwalTagihanKreditBean().execute(reportFilter);break;
             case 338 : new RptNominatifKreditPerGroupBean().execute(reportFilter);break;
             case 339 : new RptNominatifKreditBean().execute(reportFilter);break;
             case 340 : new RptNominatifPPAPWDBean().execute(reportFilter);break;
             case 341 : new RptRealisasiKreditBean().execute(reportFilter);break;
             case 342 : new RptRekapKreditBean().execute(reportFilter);break;
             case 343 : new RptRiwayatKreditBean().execute(reportFilter);break;
             case 344 : new RptTransaksiKreditBean().execute(reportFilter);break;
             case 345 : new RptTunggakanKreditBean().execute(reportFilter);break;
             case 346 : new SppkBean().execute(reportFilter);break;
             case 347 : new PerjanjianKreditBean().execute(reportFilter);break;
             case 348 : new KwitansiPertamaBean().execute(reportFilter);break;
             case 349 : new KwitansiTagihanBean().execute(reportFilter);break;    
         }
      /* 
            
            case 332 : new rptAccrualAnggaranKreditBean().execute();
            case 333 : new rptAccrualPeroranganBean().execute();
            case 334 : new rptAnalisaKolektibilitasBean().execute();
           
            
            
        
          
            
        
       
        * 
        */
    }

    public boolean isShowLookup() {
        return showLookup;
    }

    public void setShowLookup(boolean showLookup) {
        this.showLookup = showLookup;
    }
    
     public void showDialog(String value) {
        value+=".show();";
        RequestContext.getCurrentInstance().execute(value);
    }
    
     public void handleCloseLookup(CloseEvent event) {
        this.showLookup=false;
    }
     
     public void prepareCif(String cif) {
        reportFilter.setCif(cif);
    } 
     
     public void prepareTransNo(String TransNo) {
        reportFilter.setTransNo(TransNo);
    } 
     
      public void prepareMarketing(Integer marketingId,String Marketing) {
        reportFilter.setMarketingId(marketingId);
        reportFilter.setMarketingName(Marketing);
    }
}
